package com.golxen.framework.common.server.agent.cmd;


import com.golxen.framework.AgentProtocol;
import com.golxen.framework.PBPacket.PBPacket;
import com.golxen.framework.common.server.game.cmd.Cmd;
import com.golxen.framework.common.server.game.cmd.Command;
import com.golxen.framework.netty.session.agent.ServerClientMgr;
import com.golxen.protojava.LoadProto;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = AgentProtocol.A_CROSS_HEART_CHECK, desc = "跨服服务器心跳检测")
public class CrossServerHeartCheckCmd implements Command {
    @Override
    public Tuple execute(ChannelHandlerContext ctx, PBPacket packet) throws Exception {
        LoadProto.CheckManyCrossConnectMsg msg = LoadProto.CheckManyCrossConnectMsg.parseFrom(packet.getBytes());
        int id = 0;
        int index = 0;
        if (msg.hasId()) {
            id = msg.getId();
        }
        if (msg.hasIndex()){
            index= msg.getIndex();
        }
        ServerClientMgr.setCrossConnSetCheckTime(index, msg.getServerType(), id);
        return new Tuple(null, msg);
    }
}
